package com.gmail.bogatyr.alexander.somint.controller;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

/**
 *
 * @author Alexander
 */
@Controller
public class NoteController extends BaseController {

    @RequestMapping(value = "/json/note/getAll.htm", method = RequestMethod.GET)
    public ModelAndView getAll() throws JSONException {
        ModelAndView model = createModelAndJsonView();
        JSONArray data = new JSONArray();
        data.put(new JSONObject()
                .append("id", "1")
                .append("name", "Development")
                .append("description", "description"));
        data.put(new JSONObject()
                .append("id", "2")
                .append("name", "Development1")
                .append("description", "Description1"));
        data.put(new JSONObject()
                .append("id", "3")
                .append("name", "Development2")
                .append("description", "Description2"));
        model.addObject(DATA, data);
        return model;
    }
}
